package com.qianyu.project.web.controller.sy;

import com.qianyu.project.entity.ContractReceipt;
import com.qianyu.project.service.IContractReceiptService;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import org.apache.poi.util.Removal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("contractReceipt")
public class ContractReceiptController {
    @Autowired
    private IContractReceiptService contractReceiptService;

    @GetMapping("getMaxId")
    public Result getMaxId(){
        return ResultTool.success(Long.valueOf(contractReceiptService.getMaxId()) + 1);
    }

    @PostMapping
    public Result save(@RequestBody ContractReceipt contractReceipt){
        contractReceiptService.saveDetail(contractReceipt);
        return ResultTool.success();
    }

    @GetMapping
    public Result getList(@RequestParam Map<String, String> params){
        return ResultTool.success(contractReceiptService.getList(params));
    }

    @GetMapping("{id}")
    public Result selectOne(@PathVariable String id){
        return ResultTool.success(contractReceiptService.selectOne(id));
    }
}
